//
//  HJSearchView.m
//  KaiChat
//
//  Created by lx on 2023/11/20.
//

#import "HJSearchView.h"
#import "QMUIButton.h"

@interface HJSearchView()

@property (nonatomic, weak) QMUIButton *clearButton;

@end


@implementation HJSearchView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = UIColor.tj_F6F6F6Color;
        self.addCornerRadius(10);
   
        UIImageView *searchIcon = [UIImageView addToView:self];
        searchIcon.image = [UIImage imageNamed:@"search_icon"];
        CGSize size = searchIcon.image.size;
        [searchIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.left.offset(15);
            make.height.offset(size.height);
            make.width.offset(size.width);
        }];

        QMUITextField *textField = [QMUITextField addToView:self];
        textField.placeholder = @"Search";
        textField.font = UIFontMake(14);
        textField.returnKeyType = UIReturnKeyDone;
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(searchIcon.mas_right).offset(10);
            make.right.inset(15);
            make.top.bottom.offset(0);
        }];
        
        _textField = textField;
    }
    return self;
}

@end
